<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: SamplePhyLayer Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00190.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">SamplePhyLayer Class Reference<div class="ingroups"><a class="el" href="a00510.html">phyLayer - physical layer modules</a> &#124; <a class="el" href="a00527.html">AnalogueModels example - Classes from the AnalogueModels example</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="SamplePhyLayer" --><!-- doxytag: inherits="PhyLayer" -->
<p>Simple <a class="el" href="a00173.html" title="Provides initialisation for several AnalogueModels and Deciders from modules directory.">PhyLayer</a> sub class which is just responsible for creating and initialising its own AnalogueModels and <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a>.  
 <a href="a00190.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00234_source.html">SamplePhyLayer.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for SamplePhyLayer:</div>
<div class="dyncontent">
<div class="center"><img src="a00989.png" border="0" usemap="#SamplePhyLayer_inherit__map" alt="Inheritance graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for SamplePhyLayer:</div>
<div class="dyncontent">
<div class="center"><img src="a00990.png" border="0" usemap="#SamplePhyLayer_coll__map" alt="Collaboration graph"/></div>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>

<p><a href="a00991.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00190.html#a51d4997ab7973ee4b174ae49fb9b658f">initialize</a> (int stage)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">OMNeT++ initialization function.  <a href="#a51d4997ab7973ee4b174ae49fb9b658f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00190.html#aea91987fbece2dea329cf0a24dfa5450">handleMessage</a> (cMessage *msg)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Normally a sub-classed phy-layer doesn't has to implement this method. We are only doing this to display some messages telling the current state.  <a href="#aea91987fbece2dea329cf0a24dfa5450"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="a00009.html">AnalogueModel</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00190.html#a4a7e75e458a9e9ea62bd933378baa7d7">getAnalogueModelFromName</a> (const std::string &amp;name, <a class="el" href="a00079.html#a37995e7f41efc2f95b081653ca01b482">ParameterMap</a> &amp;params) const </td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates and returns an instance of the <a class="el" href="a00009.html" title="Interface for the analogue models of the physical layer.">AnalogueModel</a> with the specified name.  <a href="#a4a7e75e458a9e9ea62bd933378baa7d7"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="a00070.html">Decider</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00190.html#ad2c09c9853706c2949e06dd9e4fb0739">getDeciderFromName</a> (const std::string &amp;name, <a class="el" href="a00079.html#a37995e7f41efc2f95b081653ca01b482">ParameterMap</a> &amp;params)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">This method is called by the <a class="el" href="a00173.html" title="Provides initialisation for several AnalogueModels and Deciders from modules directory.">PhyLayer</a> to initialize the decider read from the config.xml.  <a href="#ad2c09c9853706c2949e06dd9e4fb0739"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac5a75e29cb99697bfcf7549ad5381db9"></a><!-- doxytag: member="SamplePhyLayer::log" ref="ac5a75e29cb99697bfcf7549ad5381db9" args="(std::string msg) const " -->
void&#160;</td><td class="memItemRight" valign="bottom"><b>log</b> (std::string msg) const </td></tr>
<tr><td class="memTemplParams" colspan="2">template&lt;class T &gt; </td></tr>
<tr><td class="memTemplItemLeft" align="right" valign="top">std::string&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="a00190.html#aa61c5b8f1e8b668d04515b0ce21983fb">toString</a> (const T &amp;v) const </td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Simple <a class="el" href="a00173.html" title="Provides initialisation for several AnalogueModels and Deciders from modules directory.">PhyLayer</a> sub class which is just responsible for creating and initialising its own AnalogueModels and <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a>. </p>
<p>Initializing own AnalogueModels or <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> is the only task a PhyLayer- subclass will normally have to do. Everything else should be already done by the <a class="el" href="a00173.html" title="Provides initialisation for several AnalogueModels and Deciders from modules directory.">PhyLayer</a> or should be implemented by writing your own <a class="el" href="a00070.html" title="The basic Decider class.">Decider</a> or AnalogueModels. </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a4a7e75e458a9e9ea62bd933378baa7d7"></a><!-- doxytag: member="SamplePhyLayer::getAnalogueModelFromName" ref="a4a7e75e458a9e9ea62bd933378baa7d7" args="(const std::string &amp;name, ParameterMap &amp;params) const " -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00009.html">AnalogueModel</a> * SamplePhyLayer::getAnalogueModelFromName </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a00079.html#a37995e7f41efc2f95b081653ca01b482">ParameterMap</a> &amp;&#160;</td>
          <td class="paramname"><em>params</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const<code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Creates and returns an instance of the <a class="el" href="a00009.html" title="Interface for the analogue models of the physical layer.">AnalogueModel</a> with the specified name. </p>
<p>Is able to initialize the following AnalogueModels:</p>
<ul>
<li><a class="el" href="a00184.html" title="Sample implementation of an AnalogueModel which uses MultiDimMapping as AttenuationMapping.">RandomFreqTimeModel</a></li>
<li><a class="el" href="a00185.html" title="Sample implementation of an AnalogueModel which uses MultiDimMapping as AttenuationMapping.">RandomFrequencyOnlyModel</a> </li>
</ul>

<p>Reimplemented from <a class="el" href="a00173.html#aaecc372ab08295d393581440b326922f">PhyLayer</a>.</p>
<div class="fragment"><pre class="fragment">                                                                                                         {

  <span class="keywordflow">if</span>(name == <span class="stringliteral">&quot;RandomFreqTimeModel&quot;</span>)
    <span class="keywordflow">return</span> createAnalogueModel&lt;RandomFreqTimeModel&gt;(params);
  <span class="keywordflow">if</span>(name == <span class="stringliteral">&quot;RandomFrequencyOnlyModel&quot;</span>)
    <span class="keywordflow">return</span> createAnalogueModel&lt;RandomFrequencyOnlyModel&gt;(params);

  <span class="comment">//If we couldn&#39;t create the passed analogue model, call the method</span>
  <span class="comment">//of our base class.</span>
  <span class="comment">//Note: even if all models defined in the xml-config can be handled</span>
  <span class="comment">//by this class method, there will be at least the call to create</span>
  <span class="comment">//the RadioStateAnalogueModel which in almost every case has to be done</span>
  <span class="comment">//by the PhyLayer.</span>
  <span class="keywordflow">return</span> <a class="code" href="a00190.html#a4a7e75e458a9e9ea62bd933378baa7d7" title="Creates and returns an instance of the AnalogueModel with the specified name.">PhyLayer::getAnalogueModelFromName</a>(name, params);
}
</pre></div>
</div>
</div>
<a class="anchor" id="ad2c09c9853706c2949e06dd9e4fb0739"></a><!-- doxytag: member="SamplePhyLayer::getDeciderFromName" ref="ad2c09c9853706c2949e06dd9e4fb0739" args="(const std::string &amp;name, ParameterMap &amp;params)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a00070.html">Decider</a> * SamplePhyLayer::getDeciderFromName </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a00079.html#a37995e7f41efc2f95b081653ca01b482">ParameterMap</a> &amp;&#160;</td>
          <td class="paramname"><em>params</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [protected, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>This method is called by the <a class="el" href="a00173.html" title="Provides initialisation for several AnalogueModels and Deciders from modules directory.">PhyLayer</a> to initialize the decider read from the config.xml. </p>
<p>Every decider which should be usable by a Simulation using this class has to be known by either this method or (one of) the base methods.</p>
<p>Is able to initialize directly the following decider:</p>
<ul>
<li><a class="el" href="a00209.html" title="A simple Decider implementation which only checks for a received signal if the receiving power is abo...">ThresholdDecider</a> </li>
</ul>

<p>Reimplemented from <a class="el" href="a00173.html#a6f0907cd759351336c159c6e222beceb">PhyLayer</a>.</p>
<div class="fragment"><pre class="fragment">                                                                                       {

  <span class="keywordflow">if</span>(name == <span class="stringliteral">&quot;ThresholdDecider&quot;</span>){
      <span class="keywordflow">return</span> createDecider&lt;ThresholdDecider&gt;(params);
  }

  <span class="keywordflow">return</span> <a class="code" href="a00190.html#ad2c09c9853706c2949e06dd9e4fb0739" title="This method is called by the PhyLayer to initialize the decider read from the config.xml.">PhyLayer::getDeciderFromName</a>(name, params);
}
</pre></div>
</div>
</div>
<a class="anchor" id="aea91987fbece2dea329cf0a24dfa5450"></a><!-- doxytag: member="SamplePhyLayer::handleMessage" ref="aea91987fbece2dea329cf0a24dfa5450" args="(cMessage *msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SamplePhyLayer::handleMessage </td>
          <td>(</td>
          <td class="paramtype">cMessage *&#160;</td>
          <td class="paramname"><em>msg</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Normally a sub-classed phy-layer doesn't has to implement this method. We are only doing this to display some messages telling the current state. </p>
<p>Note: IF a subclass overrides this method it should make sure to call the base method. </p>

<p>Reimplemented from <a class="el" href="a00029.html#a3880154c8db8b8efb5315cb6ef8f6c41">BasePhyLayer</a>.</p>

<p>References <a class="el" href="a00134.html#a36bc50a86bf1cc0f9efd374613d61a52a96eafe94b4f472727793a10013af7671">MacToPhyInterface::AIR_FRAME</a>, <a class="el" href="a00029.html#a4cd91821a30270d51c4c66594b9d7122a8c8f8a59dc873e035f19750598ceb157">BasePhyLayer::END_RECEIVE</a>, <a class="el" href="a00029.html#a4cd91821a30270d51c4c66594b9d7122a2900d4f5f03ec09b83e5c24744924755">BasePhyLayer::RECEIVING</a>, and <a class="el" href="a00029.html#a4cd91821a30270d51c4c66594b9d7122aa0cb17278ea70e7e327de30aad32e0a0">BasePhyLayer::START_RECEIVE</a>.</p>
<div class="fragment"><pre class="fragment">                                                {
  <span class="keywordflow">if</span>(msg-&gt;getKind() == <a class="code" href="a00134.html#a36bc50a86bf1cc0f9efd374613d61a52a96eafe94b4f472727793a10013af7671" title="AirFrame kind.">AIR_FRAME</a>) {
    airframe_ptr_t frame = <span class="keyword">static_cast&lt;</span>airframe_ptr_t<span class="keyword">&gt;</span>(msg);

    <span class="comment">//normally a subclassed phylayer doesn&#39;t has to care about these</span>
    <span class="comment">//events, we only catch them to display some messages telling the</span>
    <span class="comment">//current state of the receiving process</span>
    <span class="keywordflow">switch</span>(frame-&gt;getState()) {
    <span class="keywordflow">case</span> <a class="code" href="a00029.html#a4cd91821a30270d51c4c66594b9d7122aa0cb17278ea70e7e327de30aad32e0a0" title="Start of actual receiving process of the AirFrame.">START_RECEIVE</a>:
      <span class="keywordflow">if</span>(frame-&gt;getSignal().getReceptionStart() != simTime())
        log(<span class="stringliteral">&quot;Received delayed AirFrame (state=START_RECEIVE). Proceeding it directly to RECEIVING state&quot;</span>);
      <span class="keywordflow">else</span>
        log(<span class="stringliteral">&quot;Received AirFrame (state=START_RECEIVE). Proceeding it directly to RECEIVING state&quot;</span>);
      <span class="keywordflow">break</span>;

    <span class="keywordflow">case</span> <a class="code" href="a00029.html#a4cd91821a30270d51c4c66594b9d7122a2900d4f5f03ec09b83e5c24744924755" title="AirFrame is being received.">RECEIVING</a>:
      log(<span class="stringliteral">&quot;Received scheduled AirFrame for further processing through the decider.&quot;</span>);
      <span class="keywordflow">break</span>;

    <span class="keywordflow">case</span> <a class="code" href="a00029.html#a4cd91821a30270d51c4c66594b9d7122a8c8f8a59dc873e035f19750598ceb157" title="Receiving process over.">END_RECEIVE</a>:
      log(<span class="stringliteral">&quot;Last receive of scheduled AirFrame because AirFrame transmission is over. (state=END_RECEIVE&quot;</span>);
      <span class="keywordflow">break</span>;

    <span class="keywordflow">default</span>:
      <span class="keywordflow">break</span>;
    }
  }

  <span class="comment">//IF a subclass of PhyLayer overrides the handleMessage method it should</span>
  <span class="comment">//make sure to call the base method.</span>
  <a class="code" href="a00190.html#aea91987fbece2dea329cf0a24dfa5450" title="Normally a sub-classed phy-layer doesn&#39;t has to implement this method. We are only doing this to disp...">PhyLayer::handleMessage</a>(msg);
}
</pre></div>
</div>
</div>
<a class="anchor" id="a51d4997ab7973ee4b174ae49fb9b658f"></a><!-- doxytag: member="SamplePhyLayer::initialize" ref="a51d4997ab7973ee4b174ae49fb9b658f" args="(int stage)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SamplePhyLayer::initialize </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>stage</em></td><td>)</td>
          <td><code> [virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>OMNeT++ initialization function. </p>
<p>Read simple parameters. Read and parse xml file for decider and analogue models configuration. </p>

<p>Reimplemented from <a class="el" href="a00029.html#a08704deaf03b73c8eda67cc60e670853">BasePhyLayer</a>.</p>
<div class="fragment"><pre class="fragment">                                         {
  <span class="comment">//call BasePhy&#39;s initialize</span>
  <a class="code" href="a00190.html#a51d4997ab7973ee4b174ae49fb9b658f" title="OMNeT++ initialization function.">PhyLayer::initialize</a>(stage);

  <span class="keywordflow">if</span>(stage == 0) {
  } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(stage == 1) {
    <span class="comment">//Decider and AnalogueModels are created by the PhyLayer in this stage</span>
  }
}
</pre></div>
</div>
</div>
<a class="anchor" id="aa61c5b8f1e8b668d04515b0ce21983fb"></a><!-- doxytag: member="SamplePhyLayer::toString" ref="aa61c5b8f1e8b668d04515b0ce21983fb" args="(const T &amp;v) const " -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">std::string SamplePhyLayer::toString </td>
          <td>(</td>
          <td class="paramtype">const T &amp;&#160;</td>
          <td class="paramname"><em>v</em></td><td>)</td>
          <td> const<code> [inline, protected]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Converts the passed value to a string. There has to be an implementation of the &lt;&lt; operator for the type of the variable and std::ostream:</p>
<p>std::ostream&amp; operator&lt;&lt;(std::ostream&amp; o, const T&amp; v) </p>
<div class="fragment"><pre class="fragment">                                                         {
    std::ostringstream o;
    o &lt;&lt; v;
    <span class="keywordflow">return</span> o.str();
  };
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/examples/analogueModels/<a class="el" href="a00234_source.html">SamplePhyLayer.h</a></li>
<li>D:/Projects/MiXiM/extsrc/mixim/examples/analogueModels/SamplePhyLayer.cc</li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00190.html">SamplePhyLayer</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:33 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
